<?php

namespace co2_OS;

use co2\dev\v0_0_0 as api;

function install_api($version,$channel='stable')

{
  log::register("INSTALL_API: Received install signal for API version $version from channel $channel");
   
  $dir=sysvar::get('kernel')."/api/$channel/$version";
  
  if(is_dir($dir))
  
  {
    log::register("INSTALL_API: API version $version from channel $channel already installed");
    
    throw new api\Exception('API version '.$version.' from channel '.$channel.' is already installed',null,ES_API_VERSION_ALREADY_INSTALLED);
  }
  
  aptitude::add(aptitude::TYPE_API,'api',$version,$channel);
  
  log::register("INSTALL_API: OK :)");
}
